#ifndef __STATUSBAR_EXT__
#define __STATUSBAR_EXT__

#include <QStatusBar>
#include <QMainWindow>
#include "factory.h"
#include <string>

class StatusBar
{
  public:
    StatusBar();
    virtual ~StatusBar();

    static StatusBar* getStatusBar(QMainWindow *pmainWnd = 0) {
      if(!pStatusBar) {
         if((pStatusBar = new(StatusBar))) {
            StatusBar::pQStatusBar = pmainWnd->statusBar();
            return pStatusBar;
         }
         else
            return 0;
       }
       else  {
         return pStatusBar;
       }
    }

    static void DeleteStatusBar()
    {
      delete pStatusBar;
      pStatusBar = 0;
    }

    bool addWidget(std::string name, QWidget *widget, int stretch = 0);

    int  insertWidget(std::string name, int index, QWidget *widget, int stretch = 0);

    bool addPermanentWidget(std::string name, QWidget *widget, int stretch = 0);

    int  insertPermanentWidget(std::string name, int index, QWidget *widget, int stretch = 0);

    void removeWidget(std::string name);

    QWidget *getWidget(std::string name);



  protected:
    static StatusBar  *pStatusBar;
    static QStatusBar *pQStatusBar;
    CFactory<QWidget> widgetFactory;
};

#endif //__STATUSBAR_EXT__
